from selenium import webdriver
from pprint import pprint
from multiprocessing import Pool
import gevent

# global driver
driver = webdriver.Chrome(executable_path=r"C:\00pcao\01soft\chromedriver.exe")
driver.get('https://www.baidu.com')


# element1 = driver.find_element_by_xpath('//input[@id="kw"]')
# element2 = driver.find_element_by_xpath('//input[@id="su"]')
# print(element1.get_attribute('name'))
# print(element2.get_attribute('value'))

def fun01(xpath):
    ele = driver.find_element_by_xpath(xpath)
    return ele


if __name__ == '__main__':
    job_list = list()
    for i in ['//input[@id="kw"]', '//input[@id="su"]']:
        g1 = gevent.spawn(fun01, i)
        job_list.append(g1)
    gevent.joinall(job_list)
    for i, g in enumerate(job_list):
        print(i)
        print(g.value.get_attribute('name'), '4444444444444444444444444444')
        print(g.value.get_attribute('value'), '555555555555555555555555555')
